/*
 * Copyright (c) 2024 Black Sesame Technologies
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "dal_fastdds/converter/LocatorKindConverter.hpp"

LocatorKindConverter* LocatorKindConverter::singleton_ = nullptr;

LocatorKindConverter::LocatorKindConverter() {}

LocatorKindConverter* LocatorKindConverter::GetInstance()
{
    if (singleton_ == nullptr) {
        singleton_ = new LocatorKindConverter();
    }
    return singleton_;
}

int32_t LocatorKindConverter::ConvertLocatorkindFromDalToFastdds(dal_locator_kind_t d_kind)
{
    int f_kind = LOCATOR_KIND_INVALID;

    switch (d_kind) {
        case DAL_LOCATOR_KIND_UDPv4:
            f_kind = LOCATOR_KIND_UDPv4;
            break;
        case DAL_LOCATOR_KIND_UDPv6:
            f_kind = LOCATOR_KIND_UDPv6;
            break;
        case DAL_LOCATOR_KIND_TCPv4:
            f_kind = LOCATOR_KIND_TCPv4;
            break;
        case DAL_LOCATOR_KIND_TCPv6:
            f_kind = LOCATOR_KIND_TCPv6;
            break;
        case DAL_LOCATOR_KIND_SHM:
            f_kind = LOCATOR_KIND_SHM;
            break;
        default:
            f_kind = LOCATOR_KIND_INVALID;
            break;
    }
    return f_kind;
}
